package com.mayikt;

import java.util.concurrent.CountDownLatch;

/**
 * @ClassName Test024
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test024 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(2);
        new Thread(() -> {
            try {
                System.out.println("t1开始执行..");
                countDownLatch.await();
                System.out.println("t1结束执行..");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "t1").start();
        new Thread(() -> {
            try {
                System.out.println("t2开始执行..");
                countDownLatch.await();
                System.out.println("t2结束执行..");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "t2").start();
        countDownLatch.countDown();
        countDownLatch.countDown();
    }
}
